home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / libc6.preinst < prev    next >
Encoding:
Text File  |  2012-06-08  |  14.3 KB  |  397 lines

  1. #!/bin/sh
  2. set -e
  3. export LC_ALL=C
  4.  
  5. type=$1
  6. preversion=$2
  7.  
  8. rm_conffile() {
  9.     local PKGNAME="$1"
  10.     local CONFFILE="$2"
  11.  
  12.     [ -e "$CONFFILE" ] || return 0
  13.  
  14.     local md5sum="$(md5sum $CONFFILE | sed -e 's/ .*//')"
  15.     local old_md5sum="$(dpkg-query -W -f='${Conffiles}' $PKGNAME | \
  16.             sed -n -e "\' $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
  17.     if [ "$md5sum" != "$old_md5sum" ]; then
  18.         echo "Obsolete conffile $CONFFILE has been modified by you."
  19.         echo "Saving as $CONFFILE.dpkg-bak ..."
  20.         mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  21.     else
  22.         echo "Removing obsolete conffile $CONFFILE ..."
  23.         rm -f "$CONFFILE"
  24.     fi
  25. }
  26.  
  27. linux_compare_versions () {
  28.     verA=$(($(echo "$1" | sed 's/^\([0-9]*\.[0-9]*\)\([^.0-9]\|$\)/\1.0\2/; s/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/')))
  29.     verB=$(($(echo "$3" | sed 's/^\([0-9]*\.[0-9]*\)\([^.0-9]\|$\)/\1.0\2/; s/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/')))
  30.  
  31.     test $verA -$2 $verB
  32. }
  33.  
  34. kfreebsd_compare_versions () {
  35.     verA=$(($(echo "$1" | sed 's/\([0-9]*\)\.\([0-9]*\).*/\1 \* 100 + \2/')))
  36.     verB=$(($(echo "$3" | sed 's/\([0-9]*\)\.\([0-9]*\).*/\1 \* 100 + \2/')))
  37.  
  38.     test $verA -$2 $verB
  39. }
  40.  
  41. kernel26_help() {
  42.     echo ""
  43.     echo "The installation of a 2.6 kernel _could_ ask you to install a new libc"
  44.     echo "first, this is NOT a bug, and should *NOT* be reported. In that case,"
  45.     echo "please add lenny sources to your /etc/apt/sources.list and run:"
  46.     echo "  apt-get install -t lenny linux-image-2.6"
  47.     echo "Then reboot into this new kernel, and proceed with your upgrade"
  48. }
  49.  
  50. if [ "$type" = upgrade ]
  51. then
  52.     # Remove old /etc/init.d/glibc.sh init script
  53.     if dpkg --compare-versions "$preversion" le "2.9-22"; then
  54.         rm_conffile libc6 "/etc/init.d/glibc.sh"
  55.     update-rc.d glibc.sh remove >/dev/null
  56.     fi
  57.  
  58.     # Load debconf module if available
  59.     if [ -f /usr/share/debconf/confmodule ] ; then
  60.         . /usr/share/debconf/confmodule
  61.     fi
  62.  
  63.     if [ -n "$preversion" ]; then
  64.     # NSS authentication trouble guard
  65.     if dpkg --compare-versions "$preversion" lt 2.11-1; then
  66.         if pidof xscreensaver xlockmore >/dev/null; then
  67.         if [ -f /usr/share/debconf/confmodule ] ; then
  68.             db_version 2.0
  69.             db_reset glibc/disable-screensaver
  70.             db_input critical glibc/disable-screensaver || true
  71.             db_go || true
  72.         else
  73.             echo "xscreensaver and xlockmore must be restarted before upgrading"
  74.             echo
  75.             echo "One or more running instances of xscreensaver or xlockmore have been"
  76.             echo "detected on this system. Because of incompatible library changes, the"
  77.             echo "upgrade of the GNU C library will leave you unable to authenticate to"
  78.             echo "these programs. You should arrange for these programs to be restarted"
  79.             echo "or stopped before continuing this upgrade, to avoid locking your users"
  80.             echo "out of their current sessions."
  81.             echo
  82.             frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  83.             if [ "$frontend" = noninteractive ]; then
  84.             echo "Non-interactive mode, upgrade glibc forcibly"
  85.             else
  86.                 echo -n "Press a key to continue"
  87.                 read answer
  88.             fi
  89.             echo
  90.         fi
  91.         fi
  92.  
  93.         check="kdm postgresql xdm"
  94.         # NSS services check: NSS_CHECK
  95.         echo -n "Checking for services that may need to be restarted..."
  96.         # Only get the ones that are installed, and configured
  97.         check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
  98.         # some init scripts don't match the package names
  99.         check=$(echo $check | \
  100.                 sed -e's/\bapache2.2-common\b/apache2/g' \
  101.                     -e's/\bat\b/atd/g' \
  102.                     -e's/\bdovecot-common\b/dovecot/g' \
  103.                     -e's/\bexim4-base\b/exim4/g' \
  104.                     -e's/\blpr\b/lpd/g' \
  105.                     -e's/\blpr-ppd\b/lpd-ppd/g' \
  106.                     -e's/\bmysql-server\b/mysql/g' \
  107.                     -e's/\bsasl2-bin\b/saslauthd/g' \
  108.         )
  109.         echo
  110.         echo "Checking init scripts..."
  111.         rl=$(runlevel | sed 's/.*\ //')
  112.         for service in $check; do
  113.             if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  114.                 invoke-rc.d ${service} status >/dev/null 2>/dev/null && status=0 || status=$?
  115.                 if [ "$status" = "0" ] || [ "$status" = "2" ] ; then
  116.                     services="$service $services"
  117.                 elif [ "$status" = "100" ] ; then
  118.                     echo "WARNING: init script for $service not found."
  119.                 fi
  120.             else
  121.                 if [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  122.                     idl=$(filerc $rl $service)
  123.                 else
  124.                     idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
  125.                 fi
  126.                 if [ -n "$idl" ] && [ -x $idl ]; then
  127.                     services="$service $services"
  128.                 fi
  129.             fi
  130.         done
  131.         if [ -n "$services" ]; then 
  132.         if [ -f /usr/share/debconf/confmodule ] ; then
  133.                 db_version 2.0
  134.             db_reset glibc/upgrade
  135.             db_subst glibc/upgrade services $services
  136.             db_input critical glibc/upgrade || true
  137.             db_go || true
  138.             db_get glibc/upgrade
  139.             answer=$RET
  140.         else
  141.             echo "Do you want to upgrade glibc now?"
  142.             echo
  143.             echo "Running services and programs that are using NSS need to be restarted,"
  144.             echo "otherwise they might not be able to do lookup or authentication any more."
  145.             echo "The installation process is able to restart some services (such as ssh or"
  146.             echo "telnetd), but other programs cannot be restarted automatically.  One such"
  147.             echo "program that needs manual stopping and restart after the glibc upgrade by"
  148.             echo "yourself is xdm - because automatic restart might disconnect your active"
  149.             echo "X11 sessions."
  150.             echo
  151.             echo "This script detected the following installed services which must be"
  152.             echo "stopped before the upgrade: $services"
  153.             echo
  154.             echo "If you want to interrupt the upgrade now and continue later, please"
  155.             echo "answer No to the question below."
  156.             echo 
  157.             frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  158.             if [ "$frontend" = noninteractive ]; then
  159.             echo "Non-interactive mode, upgrade glibc forcibly"
  160.             answer=true
  161.             else
  162.                 echo -n "Do you want to upgrade glibc now? [Y/n] "
  163.                 read answer
  164.                 case $answer in
  165.                 Y*|y*) answer=true ;;
  166.                 N*|n*) answer=false ;;
  167.                 *) answer=true ;;
  168.             esac
  169.             fi
  170.             echo
  171.         fi
  172.  
  173.         if [ "x$answer" != "xtrue" ]; then
  174.                 echo "Stopped glibc upgrade.  Please retry the upgrade after you have"
  175.                 echo "checked or stopped services by hand."
  176.                 exit 1
  177.         fi
  178.         fi
  179.     fi # end upgrading and $preversion lt 2.11-1
  180.     fi # Upgrading
  181.  
  182.     # This will keep us from using hwcap libs (optimized) during an
  183.     # upgrade.
  184.     touch /etc/ld.so.nohwcap
  185. fi
  186.  
  187. # Sanity check.
  188. # If there are versions of glibc outside of the normal installation
  189. # location (/lib, /lib64, etc.) then things may break very badly
  190. # as soon as ld.so is replaced by a new version.  This check is not
  191. # foolproof, but it's pretty accurate.  This script ignores libraries
  192. # with different sonames, and libraries incompatible with the 
  193. # to-be-installed ld.so.
  194.  
  195. check_dirs () {
  196.   for dir in $*; do
  197.     # Follow symlinks
  198.     dirlink=$(readlink -e $dir)
  199.     [ -n "$dirlink" ] && dir=$dirlink 
  200.     
  201.     # Handle /lib in LD_LIBRARY_PATH.
  202.     if expr $dir : "/lib.*" > /dev/null; then
  203.       continue
  204.     fi
  205.     # Skip ia32-libs package on ia64, and similar libraries
  206.     # (not sure why these get added to /etc/ld.so.conf)
  207.     if expr $dir : "/emul/.*" > /dev/null; then
  208.       continue
  209.     fi
  210.     if test -d $dir; then
  211.       output=$(ls $dir | egrep '^(libc.so.6|libm.so.6|libpthread.so.0|librt.so.1|libdl.so.2)$' 2>/dev/null)
  212.  
  213.       if test -n "$output"; then
  214.     # See if the found libraries are compatible with the system ld.so;
  215.     # if they aren't, they'll be ignored.  Check e_ident, e_type (which
  216.     # will just be ET_DYN), and e_machine.  If a match is found, there
  217.     # is a risk of breakage.
  218.     for lib in $output
  219.     do
  220.       if test -f "$dir/$lib"; then
  221.         libbytes=`head -c 20 $dir/$lib | od -c`
  222.         if test "$ldbytes" = "$libbytes"; then
  223.           echo "Matching libraries: $dir/$lib"
  224.           return 0
  225.         fi
  226.       fi
  227.     done
  228.       fi
  229.     fi
  230.   done
  231.   return 1
  232. }
  233.  
  234. if [ "$type" != abort-upgrade ]
  235. then
  236.   ldbytes=`head -c 20 /lib/ld-linux.so.2 | od -c`
  237.   dirs="/lib32 /lib64 /usr/local/lib /usr/local/lib32 /usr/local/lib64"
  238.   if ! test -L /usr; then
  239.     dirs="$dirs /usr/lib /usr/lib32 /usr/lib64"
  240.   fi
  241.   if check_dirs $dirs; then
  242.     echo
  243.     echo "A copy of glibc was found in an unexpected directory."
  244.     echo "It is not safe to upgrade the C library in this situation;"
  245.     echo "please remove that copy of the C library and try again."
  246.     exit 1
  247.   fi
  248.  
  249.   if test -n "$LD_LIBRARY_PATH"; then
  250.     dirs=$(echo $LD_LIBRARY_PATH | sed 's/:/ /')
  251.     if check_dirs $dirs; then
  252.       echo
  253.       echo "Another copy of the C library was found via LD_LIBRARY_PATH."
  254.       echo "It is not safe to upgrade the C library in this situation;"
  255.       echo "please remove the directory from LD_LIBRARY_PATH and try again."
  256.       exit 1
  257.     fi
  258.   fi
  259.   if test -e /etc/ld.so.conf; then
  260.     dirs=$(echo $(cat /etc/ld.so.conf))
  261.     if check_dirs $dirs; then
  262.       echo
  263.       echo "Another copy of the C library was found via /etc/ld.so.conf."
  264.       echo "It is not safe to upgrade the C library in this situation;"
  265.       echo "please remove the directory from /etc/ld.so.conf and try again."
  266.       exit 1
  267.     fi
  268.   fi
  269.   for i in ld-2.3.2.so libc-2.3.2.so ld-2.3.6.so libc-2.3.6.so ; do
  270.     if [ -e /lib/tls/$i ] && ! dpkg-query -L libc6 2>/dev/null | grep -q /lib/tls/$i ; then
  271.       echo
  272.       echo "A non-dpkg owned copy of the C library was found in /lib/tls."
  273.       echo "It is not safe to upgrade the C library in this situation;"
  274.       echo "please remove that copy of the C library and try again."
  275.       exit 1
  276.     fi
  277.   done
  278.   if [ -e /lib/tls/i686/cmov/libc.so.6 ] || [ -e /lib/i686/cmov/libc.so.6 ] ; then
  279.     status_i686=$(dpkg -s libc6-i686 2>/dev/null | grep ^Status: | sed -e 's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
  280.     status_xen=$(dpkg -s libc6-xen 2>/dev/null | grep ^Status: | sed -e 's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
  281.     if ([ -z "$status_i686" ] || [ "$status_i686" = "not-installed" ] || [ "$status_i686" = "config-files" ]) && \
  282.        ([ -z "$status_xen" ] || [ "$status_xen" = "not-installed" ] || [ "$status_xen" = "config-files" ]); then
  283.       echo
  284.       echo "A non-dpkg owned copy of the libc6-i686 package was found."
  285.       echo "It is not safe to upgrade the C library in this situation;"
  286.       echo "please remove that copy of the C library and try again."
  287.       exit 1
  288.     fi
  289.   fi
  290.   if [ -n "$LD_ASSUME_KERNEL" ] ; then
  291.     if dpkg --compare-versions "$LD_ASSUME_KERNEL" le "2.6.1"; then
  292.       echo
  293.       echo "POSIX threads library NPTL requires kernel version 2.6.1"
  294.       echo "or later.  It appears that LD_ASSUME_KERNEL is set to $LD_ASSUME_KERNEL."
  295.       echo "It is not safe to upgrade the C library in this situation;"
  296.       echo "Please unset this environment variable and try again."
  297.       exit 1
  298.     fi
  299.   fi
  300.  
  301.   # glibc kernel version check
  302.   system=`uname -s`
  303.   if [ "$system" = "Linux" ]
  304.   then
  305.       # Test to make sure z < 255, in x.y.z-n form of kernel version
  306.       # Also make sure we don't trip on x.y.zFOO-n form
  307.       kernel_rev=$(uname -r | sed 's/\([0-9]*\.\)\{1,2\}\([0-9]*\)\(.*\)/\2/')
  308.       if [ "$kernel_rev" -ge 255 ]
  309.       then
  310.           echo "WARNING: Your kernel version indicates a revision number"
  311.           echo "of 255 or greater.  Glibc has a number of built in"
  312.           echo "assumptions that this revision number is less than 255."
  313.           echo "If you\'ve built your own kernel, please make sure that any"
  314.           echo "custom version numbers are appended to the upstream"
  315.           echo "kernel number with a dash or some other delimiter."
  316.  
  317.           exit 1
  318.       fi
  319.  
  320.       # sanity checking for the appropriate kernel on each architecture.
  321.       realarch=`uname -m`
  322.       kernel_ver=`uname -r`
  323.  
  324.       # convert "armv4l" and similar to just "arm", and "mips64" and similar
  325.       # to just "mips"
  326.       case $realarch in
  327.         arm*) realarch="arm";;
  328.         mips*) realarch="mips";;
  329.       esac
  330.  
  331.       # The GNU libc requires a >= 2.6.18 kernel (except on m68k)
  332.       if [ "$realarch" != m68k ]
  333.       then
  334.           if linux_compare_versions "$kernel_ver" lt 2.6.18
  335.           then
  336.               echo WARNING: this version of the GNU libc requires kernel version
  337.               echo 2.6.18 or later.  Please upgrade your kernel before installing
  338.               echo glibc.
  339.               kernel26_help
  340.  
  341.               exit 1
  342.           fi
  343.       fi
  344.  
  345.       # The GNU libc is now built with --with-kernel= >= 2.4.1 on m68k
  346.       if [ "$realarch" = m68k ]
  347.       then
  348.           if linux_compare_versions "$kernel_ver" lt 2.4.1
  349.           then
  350.               echo WARNING: This version of glibc requires that you be running
  351.               echo kernel version 2.4.1 or later.  Earlier kernels contained
  352.               echo bugs that may render the system unusable if a modern version
  353.               echo of glibc is installed.
  354.               kernel26_help
  355.  
  356.               exit 1
  357.           fi
  358.       fi
  359.  
  360.       # From glibc 2.6-3 SPARC V8 support is dropped.
  361.       if [ "$realarch" = sparc ]
  362.       then
  363.           # The process could be run using linux32, check for /proc.
  364.           if [ -f /proc/cpuinfo ]
  365.           then
  366.              case "$(sed '/^type/!d;s/^type.*: //g' /proc/cpuinfo)" in
  367.                  sun4u)
  368.                     # UltraSPARC CPU
  369.                     ;;
  370.                  sun4v)
  371.                     # Niagara CPU
  372.                     ;;
  373.                  *)
  374.                     echo "WARNING: This machine has a SPARC V8 or earlier class processor."
  375.                     echo "Debian lenny and later does not support such old hardware"
  376.                     echo "any longer."
  377.                     exit 1
  378.                     ;;
  379.              esac
  380.           fi
  381.       fi
  382.   elif [ $system = "GNU/kFreeBSD" ] ; then
  383.       kernel_ver=`uname -r`
  384.       if kfreebsd_compare_versions "$kernel_ver" lt 6.0
  385.       then
  386.           echo WARNING: This version of glibc uses UMTX_OP_WAIT and UMTX_OP_WAKE
  387.         echo syscalls that are not present in the current running kernel. They
  388.         echo have been added in kFreeBSD 6.0.  Your system should still work,
  389.         echo but it is recommended to upgrade to a more recent version.
  390.       fi
  391.   fi
  392. fi
  393.  
  394.  
  395.  
  396. exit 0
  397.